
#include <wiisprite.h>

#include "input.h"
#include "Link.h"


using namespace Input;

Link::Link() {}

Link::~Link() {}

bool Link::Update()
{
	
	
	
	
	bool oldMoving = moving;	
	moving = MovingHeld();  
		
		
	if ((!oldMoving && moving) || !CurrDirHeld() ) // Just started moving, or the button for the current direction is up
	{	// Pick new direction
		if(DownHeld()){
			this->Face(DIR_DOWN);
		}else if(LeftHeld()){
			this->Face(DIR_LEFT);
		}else if(RightHeld()){
			this->Face(DIR_RIGHT);
		}else if(UpHeld()){
			this->Face(DIR_UP);
		}	
	}
	
	this->MovePosition(2.0f * TriHorHeld(), 2.0f * TriVerHeld());
	
	/*
	if(LeftHeld())
		{this->MovePosition(-2.0f, 0.0f);}
	if(RightHeld())
		{this->MovePosition(2.0f, 0.0f);}
	if(UpHeld())
		{this->MovePosition(0.0f, 2.0f);}
	if(DownHeld())
		{this->MovePosition(0.0f, -2.0f);}	
	
	*/
	
	
	return Creature::Update();
	
	
	
}



bool Link::CurrDirHeld()
{
	switch(currentDir)
	{
		case DIR_LEFT:
			return LeftHeld();
		case DIR_UP:
			return UpHeld();
		case DIR_DOWN:
			return DownHeld();
		case DIR_RIGHT:
			return RightHeld();	
	}
}